// Now that we've figured out everything that we're going to do, do it!
try!(queue.execute(cx.config));
+ let out_dir = cx.layout(pkg, KindTarget).build_out(pkg).display().to_string();
+ cx.compilation.extra_env.insert("OUT_DIR".to_string(), Some(out_dir));
Ok(cx.compilation)
}
assert_that(p.cargo_process("build"),
execs().with_status(0));
})
+
+test!(test_a_lib_with_a_build_command {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.5.0"
+ authors = []
+ build = "build.rs"
+ "#)
+ .file("src/lib.rs", r#"
+ include!(concat!(env!("OUT_DIR"), "/foo.rs"))
+
+ /// ```
+ /// foo::bar();
+ /// ```
+ pub fn bar() {
+ assert_eq!(foo(), 1);
+ }
+ "#)
+ .file("build.rs", r#"
+ use std::os;
+ use std::io::File;
+
+ fn main() {
+ let out = Path::new(os::getenv("OUT_DIR").unwrap());
+ File::create(&out.join("foo.rs")).write_str("
+ fn foo() -> int { 1 }
+ ").unwrap();
+ }
+ "#);
+ assert_that(p.cargo_process("test"),
+ execs().with_status(0));
+})